package chpt07;

public class AutoClosableTest implements AutoCloseable {
	public void test() {
		System.out.println("test()方法被调用");
		// 文件读取操作
	}

	@Override
	public void close() throws Exception {
		System.out.println("close()方法被调用");
	}

	public static void main(String[] args) {
		try (AutoClosableTest test = new AutoClosableTest()) {
			test.test();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}